home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / c_src2_5.zoo / inst.h < prev    next >
C/C++ Source or Header  |  1988-08-07  |  9KB  |  305 lines

  1. /************************************************************************
  2. *                                    *
  3. * The SB-Prolog System                            *
  4. * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987    *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24.  
  25. /* inst.h */
  26.  
  27. /* The followings are operand types of instructions. After these will 
  28.    be the set of all instructions. */
  29.  
  30. #define E  0
  31. #define PBB 1
  32. #define BW 2
  33. #define BC 3
  34. #define B  4
  35. #define PW  5
  36. #define PC  6
  37. #define PL  7
  38. #define BA 8
  39. #define BAA 9
  40. #define PA  10
  41. #define BL 11
  42. #define P  12
  43. #define BBB 13
  44. #define PWW 14
  45.  
  46. /* these are macros to use lpcreg as the instruction pointer and to
  47.     parse instruction operands into oprnd1, 2, and 3 */
  48.  
  49. #define parse_opPBB {lpcreg++; oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++;}
  50. #define parse_opBW {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  51. #define parse_opBC {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  52. #define parse_opB {oprnd1 = (word)*lpcreg++;}
  53. #define parse_opPW {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  54. #define parse_opPC {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  55. #define parse_opPL {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  56. #define parse_opBA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  57. #define parse_opBAA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4; oprnd3 = *(pw)lpcreg; lpcreg+=4;}
  58. #define parse_opPA {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  59. #define parse_opBL {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  60. #define parse_opP {oprnd1 = (word)*lpcreg++;}
  61. #define parse_opBBB {oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++; oprnd3 = (word)*lpcreg++;}
  62.  
  63. extern int (*p_routine[])();
  64. /* extern int (*print_routine[])(); */
  65. extern int parse_table[];
  66. extern char *inst_name[];
  67. /* extern int (*jump_table[256])(); */
  68.  
  69. /**************************************************************************/
  70.  
  71. /*    The followings are the set of all instructions.                     */
  72.  
  73. /**************************************************************************/
  74.  
  75.  
  76. /* Basic term instructions (only those with a 00 annotation are now used) */
  77.  
  78. #define getpvar00       0x00
  79. #define getpval00       0x01
  80. #define getstrv00       0x02
  81. #define gettval00       0x03
  82. #define getcon00        0x04
  83. #define getnil00        0x05
  84. #define getstr00        0x06
  85. #define getlist00       0x07
  86. #define unipvar00       0x08
  87. #define unipval00       0x09
  88. #define unitvar00       0x0a
  89. #define unitval00       0x0b
  90. #define unicon00        0x0c
  91. #define uninil00        0x0d
  92. #define getnumcon    0x0e
  93. #define putnumcon    0x0f
  94. #define putpvar00       0x10
  95. #define putpval00       0x11
  96. #define puttvar00       0x12
  97. #define putstrv00       0x13
  98. #define putcon00        0x14
  99. #define putnil00        0x15
  100. #define putstr00        0x16
  101. #define putlist00       0x17
  102. #define bldpvar00       0x18
  103. #define bldpval00       0x19
  104. #define bldtvar00       0x1a
  105. #define bldtval00       0x1b
  106. #define bldcon00        0x1c
  107. #define bldnil00        0x1d
  108. #define uninumcon    0x1e
  109. #define bldnumcon    0x1f
  110. #define getfloatcon     0x20
  111. #define putfloatcon     0x21
  112. #define unifloatcon    0x22
  113. #define bldfloatcon     0x23
  114. #define test_unifiable  0x24
  115. #define getnil01        0x25
  116. #define getstr01        0x26
  117. #define getlist01       0x27
  118. #define unipvar01       0x28
  119. #define unipval01       0x29
  120. #define unitvar01       0x2a
  121. #define unitval01       0x2b
  122. #define unicon01        0x2c
  123. #define uninil01        0x2d
  124. #define putpvar01       0x30
  125. #define putpval01       0x31
  126. #define puttvar01       0x32
  127. #define putcon01        0x34
  128. #define putnil01        0x35
  129. #define putstr01        0x36
  130. #define putlist01       0x37
  131. #define bldpvar01       0x38
  132. #define bldpval01       0x39
  133. #define bldtvar01       0x3a
  134. #define bldtval01       0x3b
  135. #define bldcon01        0x3c
  136. #define bldnil01        0x3d
  137. #define getpvar10       0x40
  138. #define getpval10       0x41
  139. #define gettval10       0x43
  140. #define getcon10        0x44
  141. #define getnil10        0x45
  142. #define getlist_k       0x46        /* known that it's a list */
  143. #define getlist_k_tvar_tvar     0x47    /* known that it's a list */
  144. #define getlist_tvar_tvar    0x48
  145. #define getcomma    0x49
  146. #define getcomma_tvar_tvar    0x4a
  147. #define unicon10        0x4c
  148. #define uninil10        0x4d
  149. #define putpvar10       0x50
  150. #define putpval10       0x51
  151. #define puttvar10       0x52
  152. #define putcon10        0x54
  153. #define putnil10        0x55
  154. #define putstr10        0x56
  155. #define putlist10       0x57
  156. #define bldpvar10       0x58
  157. #define bldpval10       0x59
  158. #define bldtvar10       0x5a
  159. #define bldtval10       0x5b
  160. #define bldcon10        0x5c
  161. #define bldnil10        0x5d
  162. #define getpvar11       0x60
  163. #define getpval11       0x61
  164. #define gettval11       0x63
  165. #define getcon11        0x64
  166. #define getnil11        0x65
  167. #define getstr11        0x66
  168. #define getlist11       0x67
  169. #define unipvar11       0x68
  170. #define unipval11       0x69
  171. #define unitvar11       0x6a
  172. #define unitval11       0x6b
  173. #define unicon11        0x6c
  174. #define uninil11        0x6d
  175. #define putpvar11       0x70
  176. #define putpval11       0x71
  177. #define puttvar11       0x72
  178. #define putcon11        0x74
  179. #define putnil11        0x75
  180. #define putstr11        0x76
  181. #define putlist11       0x77
  182. #define bldpvar11       0x78
  183. #define bldpval11       0x79
  184. #define bldtvar11       0x7a
  185. #define bldtval11       0x7b
  186. #define bldcon11        0x7c
  187. #define bldnil11        0x7d
  188.  
  189.  
  190. /* Non-determinism instructions */
  191.  
  192. #define trymeelse       0xa0
  193. #define retrymeelse     0xa1
  194. #define trustmeelsefail 0xa2
  195. #define try             0xa3
  196. #define retry           0xa4
  197. #define trust           0xa5
  198. #define getpbreg        0xa6
  199. #define gettbreg    0xa7
  200. #define putpbreg    0xa8
  201. #define puttbreg    0xa9
  202. #define jumptbreg    0xaa
  203.  
  204.  
  205.  
  206. /* Indexing instructions */
  207.  
  208. #define switchonterm    0xb0
  209. #define arg        0xb1
  210. #define arg0        0xb2    /* 3d arg is a variable */
  211. #define switchonbound    0xb3
  212. #define switchonlist    0xb4
  213.  
  214. /* tag instructions */
  215.  
  216. #define get_tag            0xbf
  217.  
  218. /* Numeric instructions */
  219.  
  220. #define movreg          0xd1
  221. #define negate        0xd2
  222. #define and         0xd3
  223. #define or         0xd4
  224. #define lshiftl        0xd5
  225. #define lshiftr        0xd6
  226. #define addreg          0xd7
  227. #define subreg          0xd8
  228. #define mulreg          0xd9
  229. #define divreg          0xda
  230. #define idivreg        0xdb    /* integer division */
  231.  
  232. /* Unsafe term instructions (only those with a 00 annotation are now used) */
  233.  
  234. #define putdval00       0xe0
  235. #define putuval00       0xe1
  236.  
  237. #define getival         0xe2
  238.  
  239. #define putuval01       0xe3
  240. #define putdval10       0xe4
  241. #define putuval10       0xe5
  242. #define putdval11       0xe6
  243.  
  244.  
  245. /* Procedure instructions */
  246.  
  247. #define unexec          0xe7
  248. #define call            0xe8
  249. #define allocate        0xe9
  250. #define deallocate      0xea
  251. #define proceed         0xeb
  252. #define execute         0xec
  253. #define unexeci         0xed
  254. #define executev        0xee
  255. #define calld           0xef
  256.  
  257.  
  258.  
  259. /* Branching instructions */
  260.  
  261. #define jump            0xf0
  262. #define jumpz           0xf1
  263. #define jumpnz          0xf2
  264. #define jumplt          0xf3
  265. #define jumple          0xf4
  266. #define jumpgt          0xf5
  267. #define jumpge          0xf6
  268.  
  269. /* Miscellaneous instructions */
  270.  
  271. #define fail            0xf8
  272. #define noop            0xf9
  273. #define halt            0xfa
  274. #define builtin         0xfb
  275. #define hash        0xfe /* only used for disassembling */
  276. #define endfile         0xff
  277.     /* virtual instruction, used for disassembler to link different segs */
  278.  
  279. extern int Switchonbound();
  280. extern int Builtin();
  281. /*
  282. extern int Getpval01();
  283. extern int Gettval01();
  284. extern int Getcon01();
  285. extern int Getnil01();
  286. extern int Getstr01();
  287. extern int Getlist01();
  288. extern int Bldpval01();
  289. extern int Bldtval01();
  290. extern int Unipvar01();
  291. extern int Unitvar01();
  292. extern int Unipval01();
  293. extern int Unitval01();
  294. extern int Unicon01();
  295. extern int Uninil01();
  296. extern int Getpval11();
  297. extern int Gettval11();
  298. extern int Getcon11();
  299. extern int Getnil11();
  300. extern int Getstr11();
  301. extern int Getlist11();
  302. extern int Bldpval11();
  303. extern int Bldtval11();
  304. */
  305.